import os

import cv2
from PIL import Image
import numpy as np
from tensorboardX import SummaryWriter

writer = SummaryWriter("datalog")
def load_data(path):
    i = 0
    for img_path in os.listdir(path):
        print(img_path)
        if img_path == "cat" or img_path == "dog":
            img_label = img_path.split(".", 1)
            img_path = path + "/" + img_path
            Suffix_name = ['.png', '.jpg', '.jpeg']
            print(img_path)
            for img_path_file in os.listdir(img_path):
                if img_path_file.endswith(tuple(Suffix_name)):
                    img_path_file = img_path + '/' + img_path_file
                    img = cv2.imread(img_path_file)
                    image_array = np.array(img)
                    writer.add_images(img_label[0],image_array,i,dataformats='HWC')
                    i += 1

load_data(path="train/")
